;;THIS IS A TEST TO SEE IF THE MAIN COPY IS AFFECTED

#|
conway-topo: An ACL2 implementation of Conway's Game of Life on several topologies
Copyright (C) 2007 Vanessa Cheney, Jennifer Foley, Gerardo Gonzalez and John O'Hare

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
|#

(include-book "world" :dir :teachpacks)



#|
Instruction Text
This is the text displayed at the bottom
of the window giving the user instructions
on how to use the software appropriately. 
|#
(defun instructionText (scene)
  (place-image
   (text "Choose starting cells using your arrow keys. Press 'Enter' to select." 11 'black) 10 900
  (place-image 
   (text "Pick a size: Press '1' for 10x10 size grid               Press '5' for 15x15 size grid        Press '2' for 20x20 size grid" 11 'black) 10 930
  (place-image 
   (text "Pick a topology: Press 'k' for klein bottle     Press 't' for torus       Press 'c' for cylinder     Press 'm' for mobius strip" 11 'black) 10 960 scene))))

#|
This function displays the big Team Turing text as well as the text over 
the input box. It calls instruction-text (I wanted to split up all the text 
into seperate functions as I was afraid these could get so big it 
would be hard to read)
|#
(defun initialText (scene)
  (instructionText 
   (place-image (text "TEAM TURING" 16 'red) 400 12
   {place-image (text "Conway's Game of Life" 11 'blue) 395 35 (empty-scene *MAIN-BOX-SIZE* *MAIN-BOX-SIZE*)})))

#|
Writes entered text into the
blue equation box on the screen
Calls determine-symbol to check which F key
was pressed, to get the appropriate expression.
Calls determine-key to see if backspace or enter
was pressed to take appropriate action. 
|#
(defun writeText (scene symbol)
      (place-image (text (string symbol) 15 'black) 500 500 scene))

#|
This function is called on redraw. It takes the current scene. And re-draws
the gui and will update the structure depending on the live cells.
|#
(defun makeGUI (newWorld)
  (writeText (initialText newWorld) (world-topology newWorld)))
;;display whatever topology from here

#|
This function determines which
function key was pressed and 
depending on which one, returns
the appropriate phrase defined in the 
directions on the interface. 
This function actually gets called on the 
first condition of write-text, not the second 
(as I previously thought)
|#
(defun determineSymbol (key)
 (if (char-equal #\k key)
     'klein
     (if (string-equal key "t")
         "torus"
         (if (string-equal key "m")
             "mobius"
             (if (string-equal key "2")
                 "20x20"
                 (if (string-equal key "5")
                     "15x15"
                       (if (string-equal key "1")
                          "10x10"
                           (if (string-equal key "c")
                               "cylinder" ;here we'll need to call a clearing function
                               (if (string-equal key "ENTER")
                                   "ENTER" ;here we'll need to call differentiate function
       "nada")))))))))

#|
Gets called on tick event. 
|#
(defun worldNext (scene)
  (initialText scene))
  ;;draw new live/dead cells


(defun handleKeyPress (newWorld key)
  (world (world-tree newWorld) (world-height newWorld) (world-width newWorld) (determineSymbol key))) 
#|
 Set width and height of main interface, clock ticks, and function to be called at initialization
(empty-scene *MAIN-BOX-SIZE* *MAIN-BOX-SIZE*)
|#
(big-bang *MAIN-BOX-SIZE* *MAIN-BOX-SIZE* 1/10 world)

#|
The function named here will be called each time when the screen is redrawn
|#
(on-redraw makeGUI)

#|
This function gets called upon each tick event. 
|#
;;(on-tick-event worldNext)

#|
The function named here will be called when a key is pressed. 
|#
(on-key-event handleKeyPress)


  



